import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import {
  DeviceRealTimeCapacity,
  DeviceRealTimeRecord,
} from "@/api/backend/index";
import qs from "qs";
export const useDeviceRealTimeCapacity = defineStore(
  Names.DeviceRealTimeCapacity,
  {
    state: () => {
      return {
        single: <any>{},
        type: <any>[],
        tags: <any>{},
      };
    },
    getters: {},
    actions: {
      //大屏产能曲线 已废弃
      getList(filter: any) {
        return new Promise((resolve, reject) => {
          _get(
            DeviceRealTimeCapacity +
              "?" +
              qs.stringify(filter, { arrayFormat: "indices" }),
            {},
            "json",
            ""
          )
            .then((res: any) => {
              console.log("大屏产能曲线", res);
              resolve(res);
            })
            .catch((err: any) => {
              console.log(err);
              reject(err);
            });
        });
      },
      getListScreen(filter: any) {
        return new Promise((resolve, reject) => {
          _get(
            DeviceRealTimeRecord +
              "/capacity?" +
              qs.stringify(filter, { arrayFormat: "indices" }),
            {},
            "json",
            ""
          )
            .then((res: any) => {
              console.log("大屏产能曲线", res);
              resolve(res);
            })
            .catch((err: any) => {
              console.log(err);
              reject(err);
            });
        });
      },
    },
  }
);
